<template>
    <div class="tipBox" @mousewheel.stop @DOMMouseScroll.stop>
        <div class="tipBox-cont">
            <div class="b_init" v-if="b_init">正在测试<img src="./../../../../actual/publicImg/dt.gif"></div>
            <div class="tipBox-cont-other" v-for="key in instruct" :class="{error:(key.err,key.results)}">
                <p v-if="!key.results">正在连接账号.测试{{key.test}}指令</p>
                <p v-if="key.results">{{key.test}}指令测试完成</p>
                <img src="./../../../../actual/publicImg/dt.gif" alt="" v-if="!key.results">
                <span v-if="key.results&&key.err==false" class="correct">&#xe649;</span>
                <span v-if="key.results&&key.err" class="error">&#xe64a;</span>
            </div>
            <div class="tipBox-cont-result" :class="{error:!consequence.is_true}" v-if="consequence.show">
                <span v-if="consequence.is_true" class="correct">&#xe6a3;</span>
                <div v-if="consequence.is_true">{{consequence.text}}</div>
                <span v-if="!consequence.is_true" class="error">&#xe64a;</span>
                <div  v-if="!consequence.is_true" v-html="consequence.text"></div>
            </div>
        </div>
        <span class="tipBox-clear" @click="test_clear"></span>
    </div>
</template>
<script>
    export default{
        data(){
            return{
                instruct:[],
                datas:[
                {
                    test:'SI',
                    cont:'密码或者账号有问题',
                    results:false,
                    number:'99',
                    err:false
                },
                {
                    test:'FDL',
                    cont:'FDL指令无权限</br>请确认填写内容,并重新测试',
                    results:false,
                    number:'98',
                    err:false
                },
                {
                    test:'MLD',
                    cont:'MLD指令无权限</br>请确认填写内容,并重新测试',
                    results:false,
                    number:'98',
                    err:false
                },
                {
                    test:'RT',
                    cont:'RT指令无权限</br>请确认填写内容,并重新测试',
                    results:false,
                    number:'97',
                    err:false
                },
                {
                    test:'DETR',
                    cont:'DETR指令无权限</br>请确认填写内容,并重新测试',
                    results:false,
                    number:'96',
                    err:false
                },
                {
                    test:'FD',
                    cont:'FD指令无权限</br>请确认填写内容,并重新测试',
                    results:false,
                    number:'95',
                    err:false
                },
                {
                    test:'FLK P',
                    cont:'FLK P指令无权限</br>请确认填写内容,并重新测试',
                    results:false,
                    number:'94',
                    err:false
                }
            ],
                consequence:{
                    text:'',
                    is_true:true,
                    show:false
                },
                b_init:true
            }
        },
        props:['newData'],
        watch:{
            newData:function () {
                this.b_init = false;
                this.instruct=[];
                this.consequence={
                    text:'',
                    is_true:true,
                    show:false
                };
                if(this.newData.success){
                    this.addText(0);
                }else {
                    if(this.newData.errorCode==99){
                        this.datas[0].cont=this.newData.message;
                        this.datas[0].err=true;
                    }else if(this.newData.errorCode==98){
                        this.datas[1].cont=this.newData.message;
                        this.datas[1].err=true;
                    }else if(this.newData.errorCode==97){
                        this.datas[2].cont=this.newData.message;
                        this.datas[2].err=true;
                    }else if(this.newData.errorCode==96){
                        this.datas[3].cont=this.newData.message;
                        this.datas[3].err=true;
                    }else if(this.newData.errorCode==95){
                        this.datas[4].cont=this.newData.message;
                        this.datas[4].err=true;
                    }else if(this.newData.errorCode==94){
                        this.datas[5].cont=this.newData.message;
                        this.datas[5].err=true;
                    }else if(this.newData.errorCode==93){
                        this.datas[6].cont=this.newData.message;
                        this.datas[6].err=true;
                    }else if(this.newData.errorCode==92){

                    }else if(this.newData.errorCode==91){

                    }else if(this.newData.errorCode==50){
                        this.datas = [
                            {
                            test:'SI',
                            cont:'密码或者账号有问题',
                            results:false,
                            number:'99',
                            err:false
                        },
                            {
                                test:'FDL',
                                cont:'FDL指令无权限</br>请确认填写内容,并重新测试',
                                results:false,
                                number:'98',
                                err:false
                            },{
                                test:'',
                                cont:this.newData.message,
                                results:false,
                                number:'50',
                                err:true
                            }]
                    }
                    this.addText(0);
                }
            }
        },
        methods:{
            asas:function () {
                alert(44)
            },
            addText:function (val) {
                if(this.datas[val]!=undefined){
                    setTimeout(()=>{
                        this.instruct.push(this.datas[val]);
                        setTimeout(()=>{
                            this.instruct[val].results=true;
                            if(this.instruct[val].err){
                                this.consequence.text=this.instruct[val].cont;
                                this.consequence.is_true=false;
                                this.consequence.show=true;
                                return;
                            }else {
                                if(val==(this.datas.length-1)){
                                    this.consequence.text='测试成功';
                                    this.consequence.show=true;
                                }else {
                                    val++;
                                    this.addText(val);
                                }
                            }
                        },1500)
                    },1500);
                }
            },
            test_clear:function () {
                this.$emit('insClear');
            }
        }
    }
</script>
<style scoped>
    .tipBox-cont-other>span {
        display: inline-block;
        font-size: 12px;
        font-family: "icon";
        vertical-align: middle;
        float: right;
        margin: 0px 50px 0px 0px;
        height: 25px;
        line-height: 25px;
    }
    .error{
        color: #d85330;
    }
    .correct{
        color: #52b676;
    }
    .b_init{
        padding: 0px 0px 0px 30px;
        color: white;
        font-size: 12px;
    }
</style>